xend, NUMA: Fix computation of needed nodes
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 14 Jan 2010 09:44:08 +0000 (09:44 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 14 Jan 2010 09:44:08 +0000 (09:44 +0000)
Enumerate the best nodes and add CPU affinity until all VCPUs can be
backed by at least one physical core. This should fix problems with
asymmetric NUMA configurations and cropped number of CPUs in Xen.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
tools/python/xen/xend/XendDomainInfo.py

index 1a5ead0d33ab7568b3da75d54cee4080a7ccab3f..6c23fc9be70c321033c32f528dad043bcdf5d4ef 100644 (file)
@@ -2724,13 +2724,12 @@ class XendDomainInfo:
                         candidate_node_list.append(i)
                 best_node = find_relaxed_node(candidate_node_list)[0]
                 cpumask = info['node_to_cpu'][best_node]
-                cores_per_node = info['nr_cpus'] / info['nr_nodes']
-                nodes_required = (self.info['VCPUs_max'] + cores_per_node - 1) / cores_per_node
-                if nodes_required > 1:
-                    log.debug("allocating %d NUMA nodes", nodes_required)
-                    best_nodes = find_relaxed_node(filter(lambda x: x != best_node, range(0,info['nr_nodes'])))
-                    for i in best_nodes[:nodes_required - 1]:
-                        cpumask = cpumask + info['node_to_cpu'][i]
+                best_nodes = find_relaxed_node(filter(lambda x: x != best_node, range(0,info['nr_nodes'])))
+                for node_idx in best_nodes:
+                    if len(cpumask) >= self.info['VCPUs_max']:
+                        break
+                    cpumask = cpumask + info['node_to_cpu'][node_idx]
+                    log.debug("allocating additional NUMA node %d", node_idx)
                 for v in range(0, self.info['VCPUs_max']):
                     xc.vcpu_setaffinity(self.domid, v, cpumask)
         return index